﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TiposComuns.Objectos
{
    /// <summary>
    /// Message posted by a user in his and his friends walls
    /// </summary>
    [Serializable]
    [System.Xml.Serialization.XmlInclude(typeof(NewFriendPost))]
    public class Post : IComparable<Post>
    {
        #region Modifiers

        private Person user;

        public string Message
        {
            get;
            set;
        }

        public DateTime Date
        {
            get;
            set;
        }

        public IDMsg ID
        {
            get;
            set;
        }

        public Person User
        {
            get { return user.Clone();}
            set { this.user = value.Clone();}
        }
        #endregion

        #region Methods
        public int CompareTo(Post post)
        {
            int i = this.Date.CompareTo(post.Date);
            if (i != 0) return i;
            else return (this==post)? 0 : -1;
        }

        public Post Clone()
        {
            Post post = new Post();
            post.Date = this.Date;
            post.ID = this.ID;
            post.Message = this.Message;
            post.User = this.User;

            return post;
        }
        #endregion
    }
}
